package files;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Formatter;
import java.util.Scanner;

public class FileTesting {
	//branch 1
	public static void main(String args[]){
		//file class
		File file = new File("C:\\newdir\\file.txt");
		if(file.exists()){
			System.out.println(file.getName() + " exists!");
		}else{
			System.out.println(file.getName() + " doesn't exist!");
		}

		final Formatter formatter;
		try {
			formatter = new Formatter("C:\\newdir\\loukas.txt");
			System.out.println("You created a file");
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		FileCreate fileCreate = new FileCreate();
		Scanner scanner = new Scanner(System.in);
		System.out.print("Enter file name: ");
		String fileName = scanner.next();
		System.out.println("Enter age: ");
		int age = scanner.nextInt();
		System.out.println("Enter name: ");
		String name = scanner.next();
		System.out.println("Enter surname: ");
		String surname = scanner.next();
		//scanner.close();
		fileCreate.createFile(fileName);
		fileCreate.addRecords(age, name, surname);
		fileCreate.closeFile();
		FileRead fileRead = new FileRead();
		System.out.print("Enter file name: ");
		String newFileName = scanner.next();
		scanner.close();
		fileRead.openFile(newFileName);
		fileRead.readFile();
		fileRead.closeFile();
	}


}
